<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="includes/Imports.jsp"%>
<title>${webinfo_title} - ${blogPost.blogPostTitle }</title>

<script type="text/javascript">
	function formAjax(id) {

		var posting = $
				.post(
						"${url_blog}/${blogPost.blogCategory.blogCategoryUrl}/${blogPost.blogPostUrl}/generateForm/"
								+ id, {});

		posting.done(function(data) {
			$('#blog_post_comment_div_' + id).append(data);
		}, 'html')

		.fail(function(jqx, err, ex) {
			alert(err + ' ' + ex);
		});

	};

	$(document).on("click", "[class=comment_reply_button]", function() {

		var id = $(this).attr('id');

		$('.blog_post_comment_div').empty();

		formAjax(id);

	});
</script>

</head>
<body>

	<!-- HEADER -->
	<div class="header_div cdf">
		<c:import url="${url_header}"></c:import>
	</div>
	<!-- END HEADER -->

	<!-- CONTENT -->
	<div class="blog_post_div cdf">
		<div class="blog_post_category_div cdf">
			<!-- NOTE: TO BE LINKED TO BLOGCATEGORY PAGE -->
			Category: ${blogPost.blogCategory.blogCategoryName}
		</div>
		<div class="blog_post_title_div cdf">${blogPost.blogPostTitle}</div>
		<div class="blog_post_author_div cdf">${blogPost.blogPostAuthor}</div>
		<div class="blog_post_content_div cdf">${blogPost.blogPostContent}</div>
		<div class="blog_post_tags_div cdf">
			Tags:
			<c:forEach items="${blogPost.blogPostTags}" var="blogPostTag">
				<!-- NOTE: TO BE LINKED TO BLOGTAGS PAGE -->
			${blogPostTag.blogTag.blogTagName}
		</c:forEach>
		</div>
		<div class="blog_post_date_div cdf">
			Last modified on:
			<fmt:formatDate value="${blogPost.blogPostDate}"
				pattern="MMMM dd, yyyy HH:mm:ss" />
		</div>
	</div>

	<c:choose>

		<c:when test="${blogPost.blogPostEnableComments}">

			<div class="blog_post_comment_form_div">

				<form:form
					action="${url_blog}/${blogPost.blogCategory.blogCategoryUrl}/${blogPost.blogPostUrl}/addComment/"
					commandName="newComment" method="post">
			Name: <form:input path="blogPostCommentName" />
					<br>
			Email: <form:input path="blogPostCommentEadd" />
					<br>
			Comment: <form:textarea path="blogPostCommentContent" />
					<br>
					<input type="submit" value="Reply">
				</form:form>

			</div>

			<div class="blog_post_comments_div cdf">
				Comments:
				<custom:comments value="${comments}" />
			</div>

		</c:when>
		<c:otherwise>
			<div>
				<i>Comments have been disabled for this Blog Post.</i>
			</div>
		</c:otherwise>

	</c:choose>

	<!-- END CONTENT -->

	<!-- FOOTER -->
	<div class="footer_div cdf">
		<c:import url="${url_footer}"></c:import>
	</div>
	<!-- END FOOTER -->

</body>
</html>